<div class="box box-info">
    <div class="box-header with-border">
        <h3 class="box-title">管理员列表</h3>

        <div class="box-tools pull-right">
            <a href="{:url('power/addMember')}" class="btn btn-sm btn-info btn-flat pull-left"><i class="fa fa-fw fa-user-plus"></i> 新增管理员</a>
        </div>
    </div>
    <!-- /.box-header -->
    <div class="box-body">
        <div class="table-responsive">
            <table class="table no-margin">
                <thead>
                    <tr>
                        <th>管理员 ID</th>
                        <th>头像</th>
                        <th>姓名</th>
                        <th>角色</th>
                        <th>邮箱</th>
                        <th>创建时间</th>
                        <th>最近登录时间</th>
                        <th>密码错误次数</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    {volist name="list" id="data"}
                    <tr>
                        <td><a href="pages/examples/invoice.html">{$data.id}</a></td>
                        <td><img class="direct-chat-img" src="{$data.avatar}" alt="message user image"></td>
                        <td>{$data.username}</td>
                        <td>{$role[$data['roleid']]??''}</td>
                        <td>{$data.email}</td>
                        <td>{$data.created_at|date="Y-m-d H:i:s",###}</td>
                        <td>{$data.logintime|date="Y-m-d H:i:s",###}</td>
                        <td>{$data.loginfailure}</td>
                        <td>{$adminStatus[$data['status']]}</td>
                        <td>
                            <a href="{:url('power/editMember',['id'=>$data->id])}" class="btn btn-info">编辑</a>
                            <!--a href="{:url('power/editMemberPriv',['id' => $data->id])}" class="btn btn-info">权限设置</a>
                            <a href="javascript:resetMemberPriv({$data->id},{$data->roleid});" class="btn btn-danger">权限初始化</a-->
                        </td>
                    </tr>
                    {/volist}
                </tbody>
            </table>
        </div>
        <!-- /.table-responsive -->
    </div>
    <!-- /.box-body -->
</div>
<script>
    /**
     * 用户权限初始化[设置为角色的权限]
     * @param {type} mid
     * @param {type} rid
     * @returns {undefined}
     */
    function resetMemberPriv(mid, rid) {
        //console.log(priv);
        stbAjax('{:Url("power/resetMemberPriv")}', {memberid: mid, roleid: rid}, function (data) {
            console.log(data);
            toast(data.code ? '成功' : '失败', data.msg, 2000);
        });
    }
</script>